<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!-- 导入头部head，js内容 -->
<%--<jsp:include page="include_javascript_head.jsp"/>--%>
<!-- 导入头部标题栏内容 -->

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String basePath2 = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path ;
	request.setAttribute("basePath", basePath) ;
	request.setAttribute("basePath2", basePath2) ;


%>
<base href="<%=basePath%>">


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>祥利百悦</title>
	<link rel="stylesheet" href="org/../css/bootstrap.min.css" />
	<link rel="stylesheet" href="org/../css/common.css" />
	<link rel="stylesheet" href="org/../css/welcome.css" />
	<link rel="stylesheet" href="org/../css/validationEngine.jquery.css" /><!--表单验证css-->
	<script type="text/javascript" src="org/../js/jquery-1.8.3.min.js"></script>
</head>
<body>

<div class="main_content create_site">
    <div class="col-xs-12 col-sm-12 div_bordered">
        <div class="panel panel-default choose_block">
            <div class="panel-heading color333">
                床位配置
                <a href="bed_add" class="btn_white2 pull-right" >&lt;快速生成</a>
            </div>
            <div class="divider"></div>
            <div class="site_block ">
                <ul class="bed_ul">
                    <li block-type='1'>
                        <div>
                            <div class="bed_li_title">楼栋(共<span class="mk_for_del">1</span>栋)</div>
                            <ul class="show_ul ul_for_building">
                                <c:forEach items="${allBuilding}" var="o"  varStatus="buildingStatus">
                                    <li class="show_lower_lever <c:if test='${o.id == currentBuilding.id}'>on</c:if>" id="building_${o.id}">
                                        <span>${o.name}</span>
                                        <span class="pull-right">
										<i class="icon_bed_edit"></i>
										<i class="icon_bed_delete"></i>
									</span>
                                    </li>
                                </c:forEach>
                            </ul>
                            <button type="button" class="btn_white2" onclick="showPopC('tankuang_for_building',this)">添加楼栋</button>
                        </div>
                    </li>
                    <li block-type='2' id="li_for_building" >
                        <div id="div_for_building_${currentBuilding.id}">
                            <div class="bed_li_title">
                                <span>A栋</span>(共
                                <span class="mk_for_del">1</span>层)
                            </div>
                            <ul class="show_ul ul_for_floor">
                                <c:forEach items="${floors}" var="floor" varStatus="floorStatus">
                                    <li class="show_lower_lever <c:if test='${floorStatus.index==0}'>on</c:if>" id="floor_${floor.id}">
                                        <span>1层</span>
                                        <span class="pull-right">
											<i class="icon_bed_edit"></i>
											<i class="icon_bed_delete"></i>
										</span>
                                    </li>
                                </c:forEach>

                            </ul>
                            <button type="button" class="btn_white2" onclick="showPopC('tankuang_for_floor',this)">添加楼层</button>
                        </div>

                    </li>
                    <li block-type='3' id="li_for_floor">
                        <div id="div_for_floor_${currentFloor.id}">
                            <div class="bed_li_title">
                                <span>A栋-1层</span>(共
                                <span class="mk_for_del">10</span>间)
                            </div>
                            <ul class="show_ul">
                                <c:forEach items="${rooms}" var="room" varStatus="roomStatus">
                                    <li class="show_lower_lever on" id="room_${room.id}">
                                        <span>A1-R1</span>
                                        <span class="pull-right">
												<i class="icon_bed_edit"></i>
												<i class="icon_bed_delete"></i>
												<i class="icon_bed_info"></i>
											  </span>
                                    </li>
                                    <li class="show_lower_lever on" id="room_${room.id}">
                                        <span>A1-R2</span>
                                        <span class="pull-right">
												<i class="icon_bed_edit"></i>
												<i class="icon_bed_delete"></i>
												<i class="icon_bed_info"></i>
											  </span>
                                    </li>
                                </c:forEach>
                            </ul>
                            <button type="button" class="btn_white2" onclick="showPopC('tankuang_for_room',this)">添加房间</button>
                        </div>
                    </li>
                    <li block-type='4' id="li_for_room">

                        <div id="div_for_room_${currentRoom.id}">
                            <div class="bed_li_title">
                                <span>A栋-1层-R1</span>(共
                                <span class="mk_for_del">1</span>张)
                            </div>
                            <ul class="show_ul ul_for_bed">
                                <c:forEach items="${beds}" var="bed" varStatus="bedStatus">
                                    <li id="bed_${bed.id}">
                                        <span>B1</span>
                                        <font class="badge_f">￥
                                            <em>1500</em>元/月</font>
                                        <input type="hidden" name="costItemId" value="${bed.costItemId}" />
                                        <span class="pull-right">
												<i class="icon_bed_edit"></i>
												<i class="icon_bed_delete"></i>
											  </span>
                                    </li>
                                </c:forEach>
                            </ul>
                            <button type="button" class="btn_white2" onclick="showPopC('tankuang_for_bed',this)">添加床位</button>
                            <input type="hidden" value="${currentRoom.roomLevel}" class="roomLevel" />
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>










<!--=======弹框开始=========-->
<!--遮罩层-->
<div class="zhy_zhezhao_pop " style="height:800px;"></div>
<!--遮罩层 end-->
<!-- 删除  -->
<div class="zhy_popa zhy_beb_pop delete_pop" >
	<p class="color66">温馨提示<span class="pull-right close_icon" onclick="hidePopC()"></span></p>
	<div class="pop_content">
		<p class="font18" >您是否确定删除该楼栋？</p>
		<div class="operate_btn pull-right">
			<button type="button" class="btn cancle_yes" id="del_submit" onclick="delSubmit(this)" >确定</button>
			<button type="button" class="btn cancle_btn" onclick="hidePopC()">取消</button>
		</div>
	</div>
</div>
<!-- 删除  2-->
<div class="zhy_popa zhy_beb_pop delete_pop2" >
	<p class="color66">温馨提示<span class="pull-right close_icon" onclick="hidePopC()"></span></p>
	<div class="pop_content">
		<p class="font18" >若删除<font class="delete_name"></font>，请先删除此<font class="delete_name"></font></font>下的信息。</p>
		<div class="operate_btn pull-right">
			<button type="button" class="btn cancle_yes" onclick="hidePopC()" >确定</button>
			<button type="button" class="btn cancle_btn" onclick="hidePopC()">取消</button>
		</div>
	</div>
</div>
<!-- 添加楼栋  -->
<div class="zhy_popa zhy_beb_pop lou_dong tankuang_for_building" >
	<p class="color66"><font>添加楼栋</font><span class="pull-right close_icon" onclick="hidePopC()"></span></p>
	<div class="pop_content">
		<form class="form-inline" id="buildingForm">
			<input type="hidden" name="station" value="${param.station }" />
			<input type="hidden" class="chenchaoUpdateBuilding" name="id" value="${param.station }" />
			<div class="form-group">
				<label class="control-label" >楼栋名：</label>
				<div class="inline">
					<div class="inline relative">
						<input type="text" name="names" class="form-control input200"  placeholder="请输入楼栋名称">
					</div>
				</div>
			</div>
			<div class="operate_btn pull-right">
				<button type="button" class="btn cancle_yes add" onclick="submitBuilding(this)">保存</button>
				<button type="button" class="btn cancle_btn " onclick="hidePopC()">取消</button>
			</div>
		</form>
	</div>
</div>
<!-- 添加楼层  -->
<div class="zhy_popa zhy_beb_pop lou_ceng tankuang_for_floor" >
	<p class="color66"><font>添加楼层</font><span class="pull-right close_icon" onclick="hidePopC()"></span></p>
	<div class="pop_content">
		<form class="form-inline" id="floorForm" >
			<input type="hidden" name="buildingId"  class="chenchao"/>
			<div class="form-group">
				<label class="control-label" >楼层名：</label>
				<div class="inline">
					<div class="inline relative">
						<input type="text" name="name" class="form-control input200 "  placeholder="请输入楼层名称">
					</div>
				</div>
			</div>

			<div class="operate_btn pull-right">
				<button type="button" class="btn cancle_yes add" onclick="submitFloor(this)" >保存</button>
				<button type="button" class="btn cancle_btn " onclick="hidePopC()">取消</button>
			</div>
		</form>
	</div>
</div>
<!-- 添加房间  -->
<div class="zhy_popa zhy_beb_pop fang_jian tankuang_for_room" >
	<p class="color66"><font>添加房间</font><span class="pull-right close_icon" onclick="hidePopC()"></span></p>
	<div class="pop_content">
		<form class="" id="roomForm">

			<input type="hidden" name="floorId" class="chenchaoFloor" />
			<input type="hidden" name="floorName"/>
			<input type="hidden" name="buildingId" class="chenchao"/>
			<input type="hidden" name="buildingName" />
			<div class="form-group">
				<label class="control-label" >房间名称：</label>
				<div class="inline">
					<input type="text" name="name" class="form-control input200 "  placeholder="请输入房间名称"><em class="colorred font12" style="display:none">* 房间名不能为空</em>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">房间面积：</label>
				<div class="inline tankuang_room_size">
					<input type="text" name="roomSize" class="form-control input200 " value="" style="margin-right: 0px;" placeholder="请输入房间面积"><em>M<sup>2</sup></em>
					<em class="colorred font12" style="display:none">* 房间面积不能为空</em>
				</div>
			</div>
			<div class="form-group mb0">
				<label class="control-label" style="vertical-align:-6px;">房间等级：</label>
				<div class="inline">
					<label class="label_radio">
						<input name="roomLevel" value="1" type="radio" onclick="setupLabel()"> 单人间
					</label>
					<label class="label_radio">
						<input name="roomLevel" value="2" type="radio" onclick="setupLabel()"> 双人间
					</label>
					<label class="label_radio">
						<input name="roomLevel" value="3" type="radio" onclick="setupLabel()"> 三人间
					</label>
					<label class="label_radio">
						<input name="roomLevel" value="4" type="radio" onclick="setupLabel()"> 四人间
					</label>
					<label class="label_radio">
						<input name="roomLevel" value="9" type="radio" onclick="setupLabel()"> 其他
					</label>
				</div>
			</div>
			<div class="form-group mb0">
				<label class="control-label" style="vertical-align:-6px;">房间类别：</label>
				<div class="inline">
					<label class="label_radio">
						<input name="roomCategory" value="1" type="radio" onclick="setupLabel()"> 一室
					</label>
					<label class="label_radio">
						<input name="roomCategory" value="2" type="radio" onclick="setupLabel()"> 一室一厅
					</label>
					<label class="label_radio">
						<input name="roomCategory" value="3" type="radio" onclick="setupLabel()"> 两室一厅
					</label>
					<label class="label_radio">
						<input name="roomCategory" value="4" type="radio" onclick="setupLabel()"> 三室一厅
					</label>
					<label class="label_radio">
						<input name="roomCategory" value="9" type="radio" onclick="setupLabel()"> 其他
					</label>
				</div>
			</div>
			<div class="form-group mb0">
				<label class="control-label" style="vertical-align:-6px;">卫生间：</label>
				<div class="inline">
					<label class="label_radio">
						<input name="roomToilet" value="1" type="radio" onclick="setupLabel()"> 有
					</label>
					<label class="label_radio">
						<input name="roomToilet" value="2" type="radio" onclick="setupLabel()"> 无
					</label>
				</div>
			</div>
			<div class="form-group mb0">
				<label class="control-label" style="vertical-align:-6px;">厨房：</label>
				<div class="inline">
					<label class="label_radio">
						<input name="roomKitchen" value="1" type="radio" onclick="setupLabel()"> 有
					</label>
					<label class="label_radio">
						<input name="roomKitchen" value="2" type="radio" onclick="setupLabel()"> 无
					</label>
				</div>
			</div>
			<div class="form-group mb0">
				<label class="control-label" style="vertical-align:-6px;">房间采光：</label>
				<div class="inline">
					<label class="label_radio">
						<input name="roomLighting" value="1" type="radio" onclick="setupLabel()"> 较好
					</label>
					<label class="label_radio">
						<input name="roomLighting" value="2" type="radio" onclick="setupLabel()"> 一般
					</label>
					<label class="label_radio">
						<input name="roomLighting" value="3" type="radio" onclick="setupLabel()"> 较差
					</label>
					<label class="label_radio">
						<input name="roomLighting" value="4" type="radio" onclick="setupLabel()"> 无采光
					</label>
				</div>
			</div>
			<div class="form-group mb0">
				<label class="control-label" style="vertical-align:-6px;">房间通风：</label>
				<div class="inline">
					<label class="label_radio">
						<input name="roomAir" value="1" type="radio" onclick="setupLabel()"> 较好
					</label>
					<label class="label_radio">
						<input name="roomAir" value="2" type="radio" onclick="setupLabel()"> 一般
					</label>
					<label class="label_radio">
						<input name="roomAir" value="3" type="radio" onclick="setupLabel()"> 较差
					</label>
					<label class="label_radio">
						<input name="roomAir" value="4" type="radio" onclick="setupLabel()"> 无通风
					</label>
				</div>
			</div>
			<div class="operate_btn pull-right">
				<button type="button" class="btn cancle_yes add" onclick="submitRoom(this)">保存</button>
				<button type="button" class="btn cancle_btn " onclick="hidePopC()">取消</button>
			</div>
		</form>
	</div>
</div>
<!-- 添加床位  -->
<div class="zhy_popa zhy_beb_pop chuang_wei tankuang_for_bed"  >
	<p class="color66"><font>添加床位</font><span class="pull-right close_icon" onclick="hidePopC()"></span></p>
	<div class="pop_contenta" >
		<form class="form-inline" id="bedForm">
			<input type="hidden" name="roomId" class="chenchaoBed" value="${currentRoom.id}"/>
            <input type="hidden" class="chenchaoPrice" name="price" value="" />
			<table class="table font14 table_fixed color333" >
				<tbody>
				<tr>
					<td class="text-center" style="border-top: 0px;border-bottom: 2px solid #e4e9ed;line-height: 25px;width: 40%;">床位名称</td>
					<td class="text-center" style="border-top: 0px;border-bottom: 2px solid #e4e9ed;line-height: 25px;width: 40%">床位费名称</td>
					<td class="text-center" style="border-top: 0px;border-bottom: 2px solid #e4e9ed;line-height: 25px;width: 20%">床位价格</td>
				</tr>
				<tr>
					<td class="text-center" ><input type="text" name="name" class="form-control input200"  placeholder="请输入床位名称"></td>
					<td class="text-center" >
						<div class="btn-group ">
							<button type="button" class="btn btn-default dropdown-text price" style="width: 106px;">请选择</button>
							<button type="button" class="btn btn-default dropdown-toggle">
								<span class="caret"></span>
								<span class="sr-only">切换下拉菜单</span>
							</button>
							<ul class="dropdown-menu" name="price">
									<li><a  class="costItem">1000</a></li>
                                    <li><a  class="costItem">1200</a></li>
                                    <li><a  class="costItem">1400</a></li>
                                    <li><a  class="costItem">1600</a></li>
                                    <li><a  class="costItem">1800</a></li>
                                    <li><a  class="costItem">2000</a></li>
                                    <li><a  class="costItem">2200</a></li>
							</ul>
							<input name="costItemIds" type="hidden" value=""/>
						</div>
					</td>
					<td class="text-center priceStr">元/月</td>
				</tr>
				</tbody>
			</table>
		</form>
	</div>
	<div class="divider" style="width: 100%;"></div>
	<div class="operate_btn text-right mb_30">
		<button type="button" class="btn cancle_yes add" onclick="submitBed(this)">保存</button>
		<button type="button" class="btn cancle_btn " onclick="hidePopC()">取消</button>
	</div>
</div>
<!--=======弹框结束=========-->
<script>
    $(function(){
        $(".dropdown-menu").children('li').bind('click', function(){

           var price =  $(this).html().split(">")[1].split("<")[0];

           var input = '<input type="" name="price" value="'+price+'" />' ;
           $(".chenchaoPrice").val(price);

        });
    });
</script>
</body>

<!--表单验证 s-->
<script type="text/javascript" src="org/../js/jquery.validationEngine-zh_CN.js" ></script>
<script type="text/javascript" src="org/../js/jquery.validationEngine.js" ></script>
<!--表单验证 e-->

<script type="text/javascript" src="org/../js/common.js" ></script>
<script>

    // 初始化导航栏
    initNavigation()
    function initNavigation() {
        $("#bedconfig_head").addClass("crent")
    }

    //全局变量
    var buildingNameRepeatFlag = 0;//楼栋名称重复提示标志，1表示已经弹出过提示框
    var bedNameRepeatFlag = 0;//床位名称重复提示标志，1表示已经弹出过提示框
    var floorNameRepeatFlag = 0;//楼层名称重复提示标志，1表示已经弹出过提示框
    var station='${param.station }';
    var tankuang_for_building=$(".tankuang_for_building").html();
    var tankuang_for_floor=$(".tankuang_for_floor").html();
    var tankuang_for_room=$(".tankuang_for_room").html();
    var tankuang_for_bed=$(".tankuang_for_bed").html();
    //	$(".form-inline").validationEngine("attach",{"binded":false});
    var hasCssClassMap={"building":"lou_dong","floor":"lou_ceng","room":"fang_jian","bed":"chuang_wei"};
    var roomInfoMap={};


    function delLowerDivTag(thisId){
        var divForThisId=$("#div_for_"+thisId);
        if(divForThisId.length==0){return}
        divForThisId.find(".show_lower_lever").each(function(){
            delLowerDivTag($(this).attr("id"));
        })
        divForThisId.remove();
    }

    function isRepeat(arr){
        var hash = {};
        for(var i=0; i<arr.length; i++) {
            if(hash[$(arr[i]).val()]) {
                return true;
            }
            hash[$(arr[i]).val()] = true;
        }
        return false;
    }

    function submitBuilding(tt){

        if (buildingNameRepeatFlag == 1) {
            return;
        }

        $(tt).prop("disabled",true);
        var url="";

        if($(tt).hasClass("add")){//添加

            url="<%=basePath2%>/save_building";

            var callback=function(buildingIdStrList){

                window.location.href="<%=basePath2%>/bed_manage?station="+station+"&buildingId="+buildingIdStrList[0];
            };
        }else{
            url="<%=basePath2%>/update_building";

            var callback=function(buildingIdStrList){
                var tankuangIdArr=$(".tankuang_for_building").attr("id").split("_");
                var thisId=tankuangIdArr[2]+"_"+tankuangIdArr[3];
                $("#"+thisId+" span:eq(0)").html($(".tankuang_for_building").find("[name=names]").val());
                //delLowerDivTag(thisId);
                hidePopC();
            };
        }
        $.ajax({
            type:"post",
            url:url,
            dataType:"json",
            data: $("#buildingForm").serialize(),
            success:function(result){

                if(result.resultCode=="SUCC"){
                    location.replace(location.href);
                    window.location.href="<%=basePath2%>/bed_manage";
                    var buildingIdStrList = eval(result.data);
                    callback(buildingIdStrList);
                }else{
                    zhyAlert(result.failureMessage);
                    $(tt).prop("disabled",false);
                }
                location.replace(location.href);
                window.location.href="<%=basePath2%>/bed_manage";
            }
        });
    }

    function submitFloor(tt){
        if (floorNameRepeatFlag == 1) {
            return;
        }

        $(tt).prop("disabled",true);
        var thisTankuang=$(".tankuang_for_floor");
        var thisIdArr=thisTankuang.attr("id").split("_");
        var thisId=thisIdArr[2]+"_"+thisIdArr[3];
		var ids = thisId.split("_")[1];
        if($(tt).hasClass("add")){//添加
            thisTankuang.find("[name=buildingId]").val(thisIdArr[3]);
            var url="<%=basePath2%>/save_floor";
            var callback=function(thisId){
                hidePopC();
                $("#div_for_"+thisId).empty();
                getFloorList(thisId.split("_"));
            };
        }else{
            var url="<%=basePath2%>/update_floor"
            var callback=function(thisId){
                $("#"+thisId+" span:eq(0)").html($(".tankuang_for_floor").find("[name=names]").val());
                delLowerDivTag(thisId);
                hidePopC();
            };
        }
        $.ajax({
            type:"post",
            url:url,
            dataType:"json",
            data: $("#floorForm").serialize(),
            success:function(result){
                if(result.resultCode=="SUCC"){
                    callback(thisId);
                }else{
                    zhyAlert(result.failureMessage);
                    $(tt).prop("disabled",false);
                }
                callback(thisId);
                window.location.href="<%=basePath2%>/bed_manage";
            }
        });
    }

    function submitRoom(tt){
        $(tt).prop("disabled",true);
        var thisTankuang=$(".tankuang_for_room");
        var thisIdArr=thisTankuang.attr("id").split("_");
        var thisId=thisIdArr[2]+"_"+thisIdArr[3];

        var roomName = thisTankuang.find("input[name='name']").val();
        if (roomName == "") {
            zhyAlert("房间名称不能为空");
            return;
        }

        var size = thisTankuang.find("input[name='roomSize']").val();
        size=size+"";
        var tipContent = validateRoomSize(size);
        if (tipContent != "") {
            zhyAlert(tipContent);
            return;
        }

        if($(tt).hasClass("add")){//添加
            var url="<%=basePath2%>/save_room";

            var names=$("#div_for_"+thisId+" .bed_li_title span").html().split("-");
            var buildingIdDivId=$("#"+thisId).parent().parent().attr("id").split("_");
            thisTankuang.find("[name=floorId]").val(thisIdArr[3]);
            thisTankuang.find("[name=floorName]").val(names[1]);
            thisTankuang.find("[name=buildingId]").val(buildingIdDivId[3]);
            thisTankuang.find("[name=buildingName]").val(names[0]);
            var callback=function(thisId){
                hidePopC();
                $("#div_for_"+thisId).empty();
                getRoomList(thisId.split("_"));
            };
        }else{
            var url="${ctx}/cm/bedconfig/update_room";
            var callback=function(thisId){
                $("#"+thisId+" span:eq(0)").html($(".tankuang_for_room").find("[name=name]").val());
                roomInfoMap[thisId]=null;
                delLowerDivTag(thisId);
                $("#"+thisId).find(".icon_bed_info").empty();
                hidePopC();
            };
            thisTankuang.find("[name=id]").val(thisIdArr[3]);
        }

        $.ajax({
            type:"post",
            url:url,
            dataType:"json",
            data: $("#roomForm").serialize(),
            success:function(result){
                if(result.resultCode=="SUCC"){
                    callback(thisId);
                }else{
                    zhyAlert(result.failureMessage);
                    $(tt).prop("disabled",false);
                }
            }
        });
    }

    function submitBed(tt){
        if (bedNameRepeatFlag == 1) {
            return;
        }

        $(tt).prop("disabled",true);
        var thisTankuang=$(".tankuang_for_bed");
        var thisIdArr=thisTankuang.attr("id").split("_");
        var thisId=thisIdArr[2]+"_"+thisIdArr[3];//room_333

        if($(tt).hasClass("add")){//添加
            var roomId=thisTankuang.find("[name=roomId]").val();
            var url="<%=basePath2%>/save_bed";
            var callback=function(thisId){
                hidePopC();
                thisId="room_"+roomId;
                $("#div_for_"+thisId).empty();
                getRoomInfoAndBedList(thisId.split("_"),true);
            };
        }else{
            var url="<%=basePath2%>/update_bed";
            var callback=function(thisId){
                //$("#"+thisId+" span:eq(0)").html($(".tankuang_for_bed").find("[name=name]").val());
                //$("#"+thisId).find("em").html($(".tankuang_for_bed").find("[name=bedPriceStr]").val());
                var roomId=thisTankuang.find("input[name=roomId]").val();
                hidePopC();
                thisId="room_"+roomId;
                $("#div_for_"+thisId).empty();
                getRoomInfoAndBedList(thisId.split("_"),true);
            }
        }

        $.ajax({
            type:"post",
            url:url,
            dataType:"json",
            data: $("#bedForm").serialize(),
            success:function(result){
                if(result.resultCode=="SUCC"){
                    callback(thisId);
                }else{
                    zhyAlert(result.failureMessage);
                    $(tt).prop("disabled",false);
                }
            }
        });
    }
    //删除
    function delSubmit(obj){
        var thisId=$(obj).attr("title");
        var thisIdArr=thisId.split("_");

        var url = "<%=basePath2%>/del_"+thisIdArr[0]+"?id="+thisIdArr[1];

        $.ajax({
            type:"get",
            url:url,
            dataType:"json",
            success:function(result){


                    var countSpan=$("#"+thisId).parent().parent().find(".mk_for_del:last");
                    countSpan.text(countSpan.text()-1);
                    $("#"+thisId).remove();
                    delLowerDivTag(thisId);
                    hidePopC();
                    zhyAlert("删除成功");

            }

        });

        return false;
    }
    //继续添加
    function addinput(obj){
        //如果有空输入框，则不允许继续添加
        var divs = $(obj).siblings("div");
        var hasEmpty = 0;
        $.each(divs, function(n, value) {
            if ($(value).find("input[name='names']").val() == "") {
                hasEmpty = 1;
                return;
            }
        });
        if (hasEmpty == 1) {
            return;
        }

        var obj =$(obj);
        if(obj.hasClass("jxtj_for_bed")){
            if($(".tankuang_for_bed").find(".roomLevel").length>0){
                var roomLevelLeave=$(".tankuang_for_bed").find(".roomLevel").val().split("_");
                if(obj.parent().children("div").length>=(roomLevelLeave[1]-0)){
                    zhyAlert("此房间为"+roomLevelLeave[0]+",不能再添加床位");
                    return;
                }
            }
        }
        if(obj.parent().children("div").length==3){
            var err_html='<div class="error_div " style="margin-top:10px;color: #e93c46;font-size: 12px;display: none;">最多同时添加3个</div>';
            obj.parent().append(err_html);
            $(".error_div").fadeIn(800)
        }else if(obj.parent().children("div").length<=2){
            var html=obj.prev("div").html();
            // var div=$('<input type="text" name="names" class="form-control input200"  placeholder="请输入楼栋名称">');
            var div=$('<div style="margin-top:10px;" ></div>');
            div.html(html);
            obj.parent().append(div);
        }
    }

    //继续添加床位
    function addinputBed(obj){
        //如果还存在空输入框，则不允许重新添加
        var nameInputs = $("div.tankuang_for_bed").find("input[name='name']");
        var hasEmpty = 0;
        $.each(nameInputs, function(n, value) {
            if ($(value).val() == "") {
                hasEmpty = 1;
                return;
            }
        });
        if (hasEmpty == 1) {
            return;
        }

        var costItemHistoryList = ''
        var obj =$(obj);
        if(obj.siblings().find("tbody tr").length==4){
            if($(".error_div").length){
                $(".error_div").eq(0).fadeIn(800);
            }else{
                var err_html='<span class="error_div" style="line-height: 35px;color: #e93c46;font-size: 12px;display: none;">最多同时添加3个</span>';
                obj.after(err_html);
                $(".error_div").fadeIn(800);
            }
        }else if(obj.siblings("table").find("tr").length<=3){
            var html='<tr style="border-bottom: solid 1px #eeeeee">'+
                '<td class="text-center" ><input type="text" name="name" class="form-control input200"  placeholder="请输入床位"></td>'+
                '<td class="text-center">'+
                '<div class="btn-group">'+
                '<button type="button" class="btn btn-default dropdown-text" style="width: 106px;">请选择</button>'+
                '<button type="button" class="btn btn-default dropdown-toggle">'+
                '<span class="caret"></span>'+
                '<span class="sr-only">切换下拉菜单</span>'+
                '</button>'+
                '<ul class="dropdown-menu">';
            $.each(costItemHistoryList, function(n, value) {
                html = html + '<li><a href="javascript:;" onclick="setPrice(this, '+value.price+', &quot;'+value.costItemIdStr+'&quot;)">' + value.costItemName + '</a></li>';
            })
            html = html + '</ul>' +
                '<input name="costItemIds" type="hidden" value="">'+
                '</div>'+ '</td>'+
                '<td class="text-center">元/月</td>'+
                '</tr>';
            obj.siblings("table").append(html);
        }
    }

    //显示弹框,className为delete_pop是要删除。thisIdHasMember是直接显示下级有内容无法删除的信息。添加和修改的className相同，修改是flag为true；obj是一个标签，会带需要操作的信息
    function showPopC(className,obj,flag){
        obj=$(obj);
        var thisTankuang=$("."+className);

        //删除
        if(className=='delete_pop'||className=="thisIdHasMember"){
            var thisIdLi=obj.parent().parent();
            var thisId=thisIdLi.attr("id");

            /*var divForThisId=$("#div_for_"+thisId);
            var show2=false;
            if(divForThisId.length!=0){
                if(divForThisId.find(".show_lower_lever").length!=0){
                //	show2=true;
                }
            }
            if(className=="thisIdHasMember"){
                show2=true;
            } */

            /* if(show2){
                //若删除项下面有内容 楼栋下还有楼层 或楼层下还有房间
                 className= "delete_pop2";
                var thisName=$("#"+thisId+" span:eq(0)").html();
                $(".delete_name").text(thisName)
            }else{ */
            $("#del_submit").attr("title",thisId);
            var thisIdArr=thisId.split("_");

            //若删除项下面无内容
            if(thisIdArr[0]=="building"){
                thisTankuang.find(".font18").text('您是否确定删除该楼栋？');
            }else if(thisIdArr[0]=="floor"){
                thisTankuang.find(".font18").text('您是否确定删除该楼层？');
            }else if(thisIdArr[0]=="room"){
                thisTankuang.find(".font18").text('您是否确定删除该房间？');
            }else if(thisIdArr[0]=="bed"){
                thisTankuang.find(".font18").text('您是否确定删除该床位？');
            }
            //	}


        }
        //判断编辑还是添加
        if (flag) {
            thisTankuang.find(".add").removeClass("add");
            thisTankuang.attr("id","tankuang_for_"+obj.parent().parent().attr("id"));
            //thisTankuang.find("input[type=hidden]").remove();
            var thisIdArr=obj.parent().parent().attr("id").split("_");
            var hiddenIdInput=$("<input type='hidden' name='id'/>");
            hiddenIdInput.val(thisIdArr[1]);
            thisTankuang.find(".input200").parent().append(hiddenIdInput);
            if(className=="tankuang_for_bed"){
                var roomIdArr=obj.parent().parent().parent().parent().attr("id").split("_");
                thisTankuang.find("input[name='roomId']").val(roomIdArr[3]);
                hiddenIdInput.attr("name","id");
                thisTankuang.addClass("edit_chuang_wei").removeClass("chuang_wei");
                thisTankuang.children("p").children("font").text("编辑床位");
                thisTankuang.find(".input200").val(obj.parent().siblings("span").text());
                var priceInfo = obj.parent().siblings("font").text();
                thisTankuang.find(".priceStr").html(priceInfo.substring(1, priceInfo.length));
                var costItemId = obj.parent().siblings("input[name='costItemId']").val();
                thisTankuang.find("input[name='costItemIds']").val(costItemId);
                var costItemList = thisTankuang.find(".costItem");
                $.each(costItemList, function(n, value) {
                    if ($(value).attr("code") == costItemId) {
                        thisTankuang.find(".price").html($(value).html());
                    }
                });
            }else if(className=="tankuang_for_building"){
                hiddenIdInput.attr("name","buildingId");
                thisTankuang.addClass("edit_lou_dong").removeClass("lou_dong");
                thisTankuang.children("p").children("font").text("编辑楼栋名");
                thisTankuang.find(".input200").val(obj.parent().siblings("span").text());
            }else if(className=="tankuang_for_floor"){
                hiddenIdInput.attr("name","id");
                thisTankuang.addClass("edit_lou_ceng").removeClass("lou_ceng");
                thisTankuang.children("p").children("font").text("编辑楼层名");
                thisTankuang.find(".input200").val(obj.parent().siblings("span").text());
            }else if(className=="tankuang_for_room"){
                hiddenIdInput.attr("name","roomId");
                thisTankuang.addClass("edit_fang_jian").removeClass("fang_jian");
                thisTankuang.children("p").children("font").text("编辑房间");
                var data=roomInfoMap[obj.parent().parent().attr("id")];
                if(data==null){
                    $.ajax({
                        type:"get",
                        url:"<%=basePath2%>/get_room?id="+thisIdArr[1],
                        dataType:"json",
                        async: false,
                        success:function(result){
                            if(result.resultCode=="SUCC"){
                                var arr=result.data	;
                                data=arr;
                                roomInfoMap[thisId]=arr;
                            }
                        }
                    });

                }
                thisTankuang.find("input[name=name]").val(data.name);
                if (data.roomSize != 0) {
                    thisTankuang.find("input[name=roomSize]").val(data.roomSize);
                }
                thisTankuang.find("input[name=roomLevel][value="+data.roomLevel+"]").prop("checked",true);
                thisTankuang.find("input[name=roomCategory][value="+data.roomCategory+"]").prop("checked",true);
                thisTankuang.find("input[name=roomToilet][value="+data.roomToilet+"]").prop("checked",true);
                thisTankuang.find("input[name=roomKitchen][value="+data.roomKitchen+"]").prop("checked",true);
                thisTankuang.find("input[name=roomLighting][value="+data.roomLighting+"]").prop("checked",true);
                thisTankuang.find("input[name=roomAir][value="+data.roomAir+"]").prop("checked",true);
                setupLabel();
            }

        } else {
            if(className=="tankuang_for_bed"){
                var roomIdArr=obj.parent().attr("id").split("_");
                thisTankuang.find("input[name='roomId']").val(roomIdArr[3]);
                var bedCount=obj.parent().find("ul li");
                var roomLevel=obj.parent().find(".roomLevel").val();
                var str="";
                if(roomLevel==1){str="单人间"}
                if(roomLevel==2){str="双人间"}
                if(roomLevel==3){str="三人间"}
                if(roomLevel==4){str="四人间"}
                if(roomLevel>0&&roomLevel<9){
                    if(bedCount.length>=roomLevel){
                        zhyAlert("此房间为"+str+",不能再添加床位");
                        return;
                    }else{
                        $(".tankuang_for_bed").append("<input type='hidden' value='"+str+"_"+(roomLevel-bedCount.length)+"' class='roomLevel' />")
                    }
                }

            }
            var thisId=obj.parent().attr("id");
            var cssClassName=hasCssClassMap[className.split("_")[2]];//tankuang_for_floor

            thisTankuang.attr("id","tankuang"+thisId);
            thisTankuang.removeClass("edit_"+cssClassName).addClass(cssClassName);
        }
        $(".zhy_zhezhao_pop").show();
        var top = document.body.scrollTop||parent.document.documentElement.scrollTop;
        var this_h = $("." + className).height();
        var win_h = ($('html',parent.document).height()-this_h-100)/2
        $(".zhy_zhezhao_pop").height($("html").height());
        top= top +win_h;
        $("." + className).css("top", top).show().siblings(".zhy_popa").hide();
    }
    // 隐藏修改弹框
    function hidePopC() {
        $(".zhy_zhezhao_pop").hide();
        $(".zhy_popa").hide();
        resetForm();
    }
	function resetForm(){

	}
    $(".tooltip").live("mouseover",function(){
        // $(this).hide()
    })

    $(function(){
        $.ajaxSetup({ cache: false });

        //thisId是点击的标签的id，thisIdArr[0]是对应的等级，为building、floor、room三个可能值，thisIdArr[1]是对应数据库存的id，
        //例如：点击了id为building_1的li标签，则表示点击了一个楼栋，需要显示楼层的列表信息，此楼栋对应的楼层列表是存在id为div_for_building_1的div里，如果找到了就直接显示，如果没找到就构建一个放到id为li_for_building的li标签里。
        $(".bed_ul").on("click",".show_lower_lever",function(){
            var thisId=$(this).attr("id");
            var thisIdArr=thisId.split("_");
            var divForThisId=$("#div_for_"+thisId);
            $(this).parent().find(".on").removeClass("on");
            $(this).addClass("on");
            divForThisId.find(".on").removeClass("on");
            if(divForThisId.length!=0){
                $("div[id^=div_for_"+thisIdArr[0]+"]").hide();
                if(thisIdArr[0]=="building"){
                    $("div[id^=div_for_room]").hide();
                    $("div[id^=div_for_floor]").hide();
                }
                //如果点击楼层，则查询房间列表，并填入到上面的div中。
                if(thisIdArr[0]=="floor"){
                    $("div[id^=div_for_room]").hide();
                }

                divForThisId.show();
            }else{
                if($("#div_for_"+thisIdArr[0]).length){
                    $("#div_for_"+thisIdArr[0]).remove();
                }
                //构建一个列表div并显示。
                $("div[id^=div_for_"+thisIdArr[0]+"]").hide();
                var newDiv=$("<div id=div_for_"+thisId+"></div>");
                $("#li_for_"+thisIdArr[0]).append(newDiv);
                //如果点击楼栋，则查询楼层列表，并填入到上面的div中。
                if(thisIdArr[0]=="building"){
                    getFloorList(thisIdArr);
                }
                //如果点击楼层，则查询房间列表，并填入到上面的div中。
                if(thisIdArr[0]=="floor"){
                    getRoomList(thisIdArr);
                }
                //如果点击房间，则查询床位列表，并填入到上面的div中。同时查询出的房间信息放入指定的icon_bed_info，并隐藏。
                if(thisIdArr[0]=="room"){
                    getRoomInfoAndBedList(thisIdArr,true);
                }
            }
        })

        $(".bed_ul").on("mouseover",".icon_bed_info",function(){
            var thisId=$(this).parent().parent().attr("id");
            var thisIdArr=thisId.split("_");
            var tooltip=$(this).find(".tooltip");
            if(tooltip.length!=0){
                var off=$(this).offset();
                tooltip.css({
                    "top":off.top,
                    "left":(off.left+23)+'px'
                }).show();
            }else{
                if($("#div_for_"+thisId).length){
                    $("#div_for_"+thisId).remove();
                }
                //构建一个列表div并隐藏。
                var newDiv=$("<div id=div_for_"+thisId+"></div>");
                newDiv.hide();
                $("#li_for_"+thisIdArr[0]).append(newDiv);
                //查询床位列表填入到上面的div中，同时查询出的房间信息放入指定的icon_bed_info，并显示。
                getRoomInfoAndBedList(thisIdArr,false);
            }
        })

        $(".bed_ul").on("mouseout",".icon_bed_info",function(){
            var tooltip=$(this).find(".tooltip");
            if(tooltip.length!=0){
                tooltip.hide();
            }
        })

        $(".bed_ul").on("click",".icon_bed_edit",function(){
            var thisIdLi=$(this).parent().parent();
            var thisId=thisIdLi.attr("id");
            var id1 =thisId.split("_")[1] ;
			$(".chenchaoUpdateBuilding").val(id1);

            showPopC("tankuang_for_"+thisId.split("_")[0],this,true);
            return false;
        })

        $(".bed_ul").on("click",".icon_bed_delete",function(){
            showPopC("delete_pop",this);
            return false;
        })

        $(".tankuang_for_bed").on("keyup","[name=bedPriceStr]",function(){
            var price=$(this).val();
            if(price.length>9){
                price=price.substring(0,9);
                $(this).val(price);
                zhyAlert("床位价格不能大于9位");
            }

        })

        $(".tankuang_for_room").on("blur", "input[name='name']", function(){
            var name = $(this).val();
            if (name == "") {
                $(this).siblings("em").show();
            } else {
                $(this).siblings("em").hide();
            }
        });

        $(".tankuang_for_room").on("blur", "input[name='roomSize']", function(){
            var size = $(this).val();
            size=size+"";
            var tipContent = validateRoomSize(size);
            if (tipContent != "") {
                $($(this).siblings("em")[1]).html(tipContent);
                $($(this).siblings("em")[1]).show();
                $(".tankuang_for_room").find(".cancle_yes").prop("disabled",true);
            } else {
                $($(this).siblings("em")[1]).hide();
                $(".tankuang_for_room").find(".cancle_yes").prop("disabled",false);
            }
        });

        $(".tankuang_for_building").on("blur","input[name='names']", function(){
            var currentInput = $(this);
            var name = $(this).val();

            var lis = $("ul.ul_for_building >li");
            var isRepeated = 0;
            $.each(lis, function(n, value){
                var spans = $(value).find("span");
                var buildingName = $(spans[0]).html();
                if (name == buildingName) {
                    isRepeated = 1;
                    return;
                }
            });
            if (isRepeated == 1) {
                buildingNameRepeatFlag=1;
                zhyAlert("楼栋名称重复，请重新添加！");
                currentInput.val("");
                currentInput.focus();
                return;
            } else {
                buildingNameRepeatFlag=0;
            }

            var nameDivs = $(this).parent().siblings("div");
            var flag = 0;
            $.each(nameDivs, function(n, value){
                if ($(value).find("input[name='names']").val() == name) {
                    flag = 1;
                    $($(value).siblings("button")[0]).attr("disabled","disabled");
                    zhyAlert("楼栋名称重复，请重新添加！");
                    currentInput.val("");
                    currentInput.focus();
                    buildingNameRepeatFlag = 1;
                    return;
                }
            });
            if (flag == 0) {
                buildingNameRepeatFlag=0;
                $($(this).parent().siblings("button")[0]).removeAttr("disabled");
            } else {
                buildingNameRepeatFlag=1;
            }
        });

        $(".tankuang_for_floor").on("blur","input[name='names']", function(){
            var currentInput = $(this);
            var name = $(this).val();

            var visibleFloorDiv = $("#li_for_building >div:visible");
            var lis = visibleFloorDiv.find("ul.ul_for_floor >li");
            var isRepeated = 0;
            $.each(lis, function(n, value){
                var spans = $(value).find("span");
                var floorName = $(spans[0]).html();
                if (name == floorName) {
                    isRepeated = 1;
                    return;
                }
            });
            if (isRepeated == 1) {
                floorNameRepeatFlag=1
                zhyAlert("楼层名称重复，请重新添加！");
                currentInput.val("");
                currentInput.focus();
                return;
            } else {
                floorNameRepeatFlag=0;
            }

            var nameDivs = $(this).parent().siblings("div");
            var flag = 0;
            $.each(nameDivs, function(n, value){
                if ($(value).find("input[name='names']").val() == name) {
                    flag = 1;
                    $($(value).siblings("button")[0]).attr("disabled","disabled");
                    zhyAlert("楼层名称重复，请重新添加！");
                    currentInput.val("");
                    currentInput.focus();
                    floorNameRepeatFlag = 1;
                    return;
                }
            });
            if (flag == 0) {
                floorNameRepeatFlag=0;
                $($(this).parent().siblings("button")[0]).removeAttr("disabled");
            } else {
                floorNameRepeatFlag=1;
            }
        });

        $(".tankuang_for_bed").on("blur","input[name='name']", function(){
            var currentInput = $(this);
            var name = $(this).val();

            var visibleRoomDiv = $("#li_for_room >div:visible");
            var lis = visibleRoomDiv.find("ul.ul_for_bed >li");
            var isRepeated = 0;
            $.each(lis, function(n, value){
                var spans = $(value).find("span");
                var bedName = $(spans[0]).html();
                if (name == bedName) {
                    isRepeated = 1;
                    return;
                }
            });
            if (isRepeated == 1) {
                bedNameRepeatFlag = 1;
                zhyAlert("床位名称重复，请重新添加！");
                currentInput.val("");
                currentInput.focus();
                return;
            } else {
                bedNameRepeatFlag = 0;
            }

            var trs = $(this).parent().parent().siblings("tr");
            var flag = 0;
            $.each(trs, function(n, value){
                if ($(value).find("input[name='name']").val() == name) {
                    flag = 1;
                    $($(value).parent().parent().siblings("button")[0]).attr("disabled","disabled");
                    zhyAlert("床位名称重复，请重新添加！");
                    currentInput.val("");
                    currentInput.focus();
                    bedNameRepeatFlag = 1;
                    return;
                }
            });
            if (flag == 0) {
                $($(this).parent().parent().parent().siblings("button")[0]).removeAttr("disabled");
                bedNameRepeatFlag = 0;
            } else {
                bedNameRepeatFlag = 1;
            }
        });
    });
    //点击Building显示Floor列表
    function getFloorList(thisIdArr){
        var thisId=thisIdArr[0]+"_"+thisIdArr[1];
        $(".chenchao").val(thisIdArr[1]);
        $("#li_for_floor>div").hide();
        $("#li_for_room>div").hide();
        $.ajax({
            type:"get",
            url:"<%=basePath2%>/getFloor?buildingId="+thisIdArr[1],
            dataType:"json",
            success:function(result){
                if(result.resultCode=="SUCC"){
                    var data=result.data;
                    var divForThisId=$("#div_for_"+thisId);
                    //生成楼层的标题，显示上级的名称和楼层列表的数量。
                    var titleDiv=$("<div class='bed_li_title'>");
                    var titleText="<span>"+$("#"+thisId+" span:eq(0)").html()+"</span>(共<span class='mk_for_del'>"+data.length+"</span>层)";
                    titleDiv.html(titleText);
                    titleDiv.appendTo(divForThisId);
                    //生成楼层列表
                    var ul=$("<ul class='show_ul ul_for_floor'>");
                    for(var i=0;i<data.length;i++){
                        var li=$("<li class='show_lower_lever' id='floor_"+data[i].id+"'><span>"+data[i].name+"</span><span class='pull-right'><i class='icon_bed_edit'></i><i class='icon_bed_delete'></i></span></li>")
                        li.appendTo(ul);
                    }

                    ul.appendTo(divForThisId);
                    divForThisId.append("<button type='button' class='btn_white2' onclick='showPopC(\"tankuang_for_floor\",this)' >添加楼层</button>");
                    divForThisId.show();
                }else{
                    zhyAlert(result.failureMessage);
                }
            }
        });
    }

    function validateRoomSize(roomSize){
        var tipContent = "";
        var reg = new RegExp("^[0-9]*$");
        if(roomSize.length==0){
            //flag=1;
            //tipContent = "房间面积不能为空";
            return "";
        }
        if(roomSize.substring(0,1)=="-"){
            flag=1;
            tipContent = "房间面积不能为负数";
        } else if (!reg.test(roomSize)){
            flag=1;
            tipContent = "格式不对，请填入合法的整数";
        } else if (roomSize > 1000) {
            flag=1;
            tipContent = "房间面积不能大于1000";
        } else if (roomSize <= 0) {
            flag=1;
            tipContent = "房间面积必须大于0";
        }
        return tipContent;
    }

    function getRoomList(thisIdArr){
        var thisId=thisIdArr[0]+"_"+thisIdArr[1];
        $("#li_for_room>div").hide();
        $(".chenchaoFloor").val(thisIdArr[1]);
        $.ajax({
            type:"get",
            url:"<%=basePath2%>/getRoom?floorId="+thisIdArr[1],
            dataType:"json",
            success:function(result){
                if(result.resultCode=="SUCC"){
                    var data=result.data;
                    var divForThisId=$("#div_for_"+thisId);


                    //生成楼层的标题，显示上级的名称和楼层列表的数量。
                    var titleDiv=$("<div class='bed_li_title'>");

                    //原来的title加上点击的名称,例如，二号楼是从二层的上面取得，二层是从点击的位置取得
                    var titleText="<span>"+$("#"+thisId).parent().parent().find(".bed_li_title span").html()+"-"+$("#"+thisId+" span:eq(0)").html()+"</span>(共<span class='mk_for_del'>"+data.length+"</span>间)";
                    titleDiv.html(titleText).appendTo(divForThisId);
                    //生成楼层列表
                    var ul=$("<ul class='show_ul'>");
                    for(var i=0;i<data.length;i++){
                        var li=$("<li class='show_lower_lever' id='room_"+data[i].id+"'><span>"+data[i].name+"</span><span class='pull-right'><i class='icon_bed_edit'></i><i class='icon_bed_delete'></i><i class='icon_bed_info'></i></span></li>")
                        li.appendTo(ul);
                    }
                    ul.appendTo(divForThisId);
                    divForThisId.append("<button type='button' class='btn_white2' onclick='showPopC(\"tankuang_for_room\",this)' >添加房间</button>");
                }else{
                    zhyAlert(result.failureMessage);
                }
            }
        });
    }

    //flag在点击房间时有效，为true时表示点击房间，为false是表示鼠标放到房间右上角的图标上显示房间属性，
    function getRoomInfoAndBedList(thisIdArr,flag){
        var thisId=thisIdArr[0]+"_"+thisIdArr[1];
        var thisTankuang=$(".tankuang_for_bed");
        thisTankuang.find("[name=roomId]").val(thisIdArr[1]);
        $.ajax({
            type:"get",
            url:"<%=basePath2%>/getBed?roomId="+thisIdArr[1],
            dataType:"json",
            success:function(result){
                if(result.resultCode=="SUCC"){
                    var data=result.data;
                    roomInfoMap[thisId]=result.data;
                    var divForThisId=$("#div_for_"+thisId);
                    divForThisId.empty();
                    var haseBed=true;
                    var size= data.length ;

                    //如果查出的床位没有的话，不进行展示。床位数为0
                    if(data.length==0){
                        haseBed=false;
                        size=0;
                    }

                    //生成楼层的标题，显示上级的名称和楼层列表的数量。
                    var titleDiv=$("<div class='bed_li_title'>");

                    //原来的title加上点击的名称,例如，二号楼是从二层的上面取得，二层是从点击的位置取得
                    var titleText="<span>"+$("#"+thisId).parent().parent().find(".bed_li_title span").html()+"-"+$("#"+thisId+" span:eq(0)").html()+"</span>(共<span class='mk_for_del'>"+size+"</span>张)";
                    titleDiv.html(titleText).appendTo(divForThisId);
                    //生成楼层列表
                    var ul=$("<ul class='show_ul ul_for_bed'>");
                    //床位是无效的就不展示床位。
                    if(haseBed){
                        for(var i=0;i<data.length;i++){
                            var li=$("<li id='bed_"+data[i].id+"'><span>"+data[i].name+"</span><font class='badge_f'>￥<em>"+data[i].price+"</em>元/月</font><span class='pull-right'><i class='icon_bed_edit'></i><i class='icon_bed_delete'></i></span><input type='hidden' name='costItemId' value='"+data[i].costItemIdStr+"'></li>")
                            li.appendTo(ul);
                        }
                    }
                    ul.appendTo(divForThisId);
                    divForThisId.append("<button type='button' class='btn_white2' onclick='showPopC(\"tankuang_for_bed\",this)' >添加床位</button>");
                    divForThisId.append("<input type='hidden' value='"+result.roomLevel+"' class='roomLevel' />")
                    //构建房间属性div ，标志是calss为tooltip
                    var info="<div class='tooltip'><div class='tooltip-arrow'></div><div class='tooltip-inner'><div class='panel-heading color333'>房间信息</div><div class='divider'></div><div class='panel-body'>"
                        +"<p>房间名称："+titleText+"</p><p>房间面积："+getRoomSize(result.data.roomSize)+"</p><p>房间等级："+NULLtoEmpty(result.data.roomLevelName)+"</p><p>房间类别："+NULLtoEmpty(result.data.roomCategoryName)+"</p><p>卫生间："
                        +getIsHasName(result.data.roomToilet)+"</p><p>厨房："+getIsHasName(result.data.roomKitchen)+"  </p><p>房间采光："+NULLtoEmpty(result.data.roomLightingName)+"</p><p>房间通风："+NULLtoEmpty(result.data.roomAirName)+"</p></div></div></div>";
                    var infoDiv=$(info);
                    if(flag){
                        infoDiv.hide();
                    }else{
                        var off=$("#"+thisId).find(".icon_bed_info").offset();
                        infoDiv.css({
                            "top":off.top,
                            "left":(off.left+23)+'px'
                        }).show();
                    }
                    //房间属性div是放到class为icon_bed_info的i标签里
                    $("#"+thisId).find(".icon_bed_info").append(infoDiv);
                    divForThisId.find(".roomLevel").val(result.data.roomLevel);
                }else{
                    zhyAlert(result.failureMessage);
                }
            }
        });
    }

    function getRoomSize(s) {
        if (s == 0) {
            return "未知"
        } else {
            return s+"M<sup>2</sup>"
        }
    }

    function NULLtoEmpty(s){
        if(s==null){
            return "";
        }else{
            return s;
        }
    }

    function getIsHasName(no){
        if(no==1){
            return "有";
        }else if(no==2){
            return "无";
        }else{
            return "";
        }
    }

    //设置床位价格
    function setPrice(obj, price, costItemHistoryId){
        $(obj).parents("ul").next().val(costItemHistoryId);
        price = price + "";
        if (price.indexOf(".")==-1) {
            price = price + ".00";
        }
        $(obj).parents("td").next().text(price+"元/月");
    }
</script>


</html>